Skip to content

debuginfo: slices are DW_TAG_array_type's#153238

Open
shua wants to merge 2 commits into
rust-lang:mainfrom
shua:lldb-rcstr
Open

debuginfo: slices are DW_TAG_array_type's#153238
shua wants to merge 2 commits into
rust-lang:mainfrom
shua:lldb-rcstr

Conversation

@shua
Copy link
Copy Markdown

@shua shua commented Mar 1, 2026

View all comments

Rust debuginfo for unsized structs with embedded slice types is lacking, and it makes it difficult for debuggers to correctly print types like Rc<str> (eg #114195). Specifically, these three structs would have essentially the same debug info (modulo some names):

struct Foo { a: u32, s: str } // unsized
struct Bar { a: u32, s: [u8] } // unsized
struct Baz { a: u32, s: u8 }

This changes how the compiler generates debuginfo in this case, and I used existing compilers (gcc, clang) handling of C flexible member arrays as a reference.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 1, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 1, 2026

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, debuginfo
  • compiler, debuginfo expanded to 69 candidates
  • Random selection from 15 candidates

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@shua
Copy link
Copy Markdown
Author

shua commented Mar 1, 2026

another relevant thread from gdb bugtracker about rust's weird unsized type debug info and some related fixes in gdb: https://sourceware.org/bugzilla/show_bug.cgi?id=30330 . The type of change here (changing slice types to be array types with no count, similar to C's VLA/FMA) was discussed but I guess never implemented in rustc?

@rust-bors

This comment has been minimized.

Copy link
Copy Markdown
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a codegen-llvm test for the debuginfo?

View changes since this review

@Enselic Enselic added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 25, 2026
@rustbot

This comment has been minimized.

@shua
Copy link
Copy Markdown
Author

shua commented May 6, 2026

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 6, 2026
@davidtwco
Copy link
Copy Markdown
Member

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 15, 2026

📌 Commit f398585 has been approved by davidtwco

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 15, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request May 15, 2026
debuginfo: slices are DW_TAG_array_type's

Rust debuginfo for unsized structs with embedded slice types is lacking, and it makes it difficult for debuggers to correctly print types like `Rc<str>` (eg rust-lang#114195). Specifically, these three structs would have essentially the same debug info (modulo some names):
```rust
struct Foo { a: u32, s: str } // unsized
struct Bar { a: u32, s: [u8] } // unsized
struct Baz { a: u32, s: u8 }
```

This changes how the compiler generates debuginfo in this case, and I used existing compilers (gcc, clang) handling of C flexible member arrays as a reference.
rust-bors Bot pushed a commit that referenced this pull request May 15, 2026
Rollup of 11 pull requests

Successful merges:

 - #148788 (Unconstrained parameter fix)
 - #153238 (debuginfo: slices are DW_TAG_array_type's)
 - #155521 (Add lint againts invalid runtime symbol definitions)
 - #156319 (Require EIIs to be defined when we compile a rust dylib)
 - #156452 (Implement pinned drop sugar)
 - #156600 (Make const param default test reproduce original ICE)
 - #156493 (actually run the temp_dir doctest)
 - #156556 (Require UTF-8 in `Utf8Pattern::StringPattern`)
 - #156565 (delegation: emit error when self type is not specified and accessed)
 - #156586 (Use DropCtxt::new_block and new_block_with_statements systematically.)
 - #156587 (Correctly handle associated items in rustdoc macro expansion)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 15, 2026
debuginfo: slices are DW_TAG_array_type's

Rust debuginfo for unsized structs with embedded slice types is lacking, and it makes it difficult for debuggers to correctly print types like `Rc<str>` (eg rust-lang#114195). Specifically, these three structs would have essentially the same debug info (modulo some names):
```rust
struct Foo { a: u32, s: str } // unsized
struct Bar { a: u32, s: [u8] } // unsized
struct Baz { a: u32, s: u8 }
```

This changes how the compiler generates debuginfo in this case, and I used existing compilers (gcc, clang) handling of C flexible member arrays as a reference.
rust-bors Bot pushed a commit that referenced this pull request May 15, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #153238 (debuginfo: slices are DW_TAG_array_type's)
 - #156319 (Require EIIs to be defined when we compile a rust dylib)
 - #156452 (Implement pinned drop sugar)
 - #156554 (Allow user-provided `llvm_args` to override target spec arguments)
 - #156571 (Disable `main_needs_argc_argv` for Wasm)
 - #156600 (Make const param default test reproduce original ICE)
 - #156493 (actually run the temp_dir doctest)
 - #156556 (Require UTF-8 in `Utf8Pattern::StringPattern`)
 - #156565 (delegation: emit error when self type is not specified and accessed)
 - #156586 (Use DropCtxt::new_block and new_block_with_statements systematically.)
 - #156587 (Correctly handle associated items in rustdoc macro expansion)
 - #156604 (coverage: Reduce and clarify the context-mismatch test case)
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors r-
#156613 (comment)

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 15, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 15, 2026

This pull request was unapproved.

This PR was contained in a rollup (#156613), which was unapproved.

View changes since this unapproval

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 16, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@shua
Copy link
Copy Markdown
Author

shua commented May 16, 2026

Is there a way to run the tests that failed in the rollup PR (auto - aarch64-msvc-1, try - x86_64-mingw-1, try - x86_64-msvc-1) on this PR? I think I fixed the issue, but I'm not able to check msvc compile targets on my machine.

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors try jobs=aarch64-msvc-1,x86_64-mingw-1,x86_64-msvc-1

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 16, 2026
debuginfo: slices are DW_TAG_array_type's


try-job: aarch64-msvc-1
try-job: x86_64-mingw-1
try-job: x86_64-msvc-1
@rust-log-analyzer

This comment has been minimized.

@shua
Copy link
Copy Markdown
Author

shua commented May 16, 2026

@bors try jobs=aarch64-msvc-1,x86_64-mingw-1,x86_64-msvc-1

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 16, 2026

@shua: 🔑 Insufficient privileges: not in try users

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors try jobs=aarch64-msvc-1,x86_64-mingw-1,x86_64-msvc-1

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 16, 2026
debuginfo: slices are DW_TAG_array_type's


try-job: aarch64-msvc-1
try-job: x86_64-mingw-1
try-job: x86_64-msvc-1
@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job x86_64-mingw-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

---- [debuginfo-gdb] tests\debuginfo\strings-and-strs.rs stdout ----
NOTE: compiletest thinks it is using GDB version 14002000

error: check directive(s) from `D:\a\rust\rust\tests\debuginfo\strings-and-strs.rs` not found in debugger output. errors:
    (strings-and-strs.rs:30) `$7 = alloc::rc::Rc<str, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::rc::RcInner<str>> {pointer: alloc::rc::RcInner<str> {strong: core::cell::Cell<usize> {value: core::cell::UnsafeCell<usize> {value: 1}}, weak: core::cell::Cell<usize> {value: core::cell::UnsafeCell<usize> {value: 1}}, value: 0x[...]}}, phantom: core::marker::PhantomData<alloc::rc::RcInner<str>>, alloc: alloc::alloc::Global}`
the following subset of check directive(s) was found successfully:
    (strings-and-strs.rs:12) `$1 = alloc::string::String {vec: alloc::vec::Vec<u8, alloc::alloc::Global> {buf: alloc::raw_vec::RawVec<u8, alloc::alloc::Global> {inner: alloc::raw_vec::RawVecInner<alloc::alloc::Global> {ptr: core::ptr::unique::Unique<u8> {pointer: core::ptr::non_null::NonNull<u8> {pointer: 0x6a5df0}, _marker: core::marker::PhantomData<u8>}, cap: core::num::niche_types::UsizeNoHighBit (5), alloc: alloc::alloc::Global}, _marker: core::marker::PhantomData<u8>}, len: 5}}`
    (strings-and-strs.rs:15) `$2 = "Hello"`
    (strings-and-strs.rs:18) `$3 = strings_and_strs::Foo {inner: "Hello"}`
    (strings-and-strs.rs:21) `$4 = ("Hello", "World")`
    (strings-and-strs.rs:24) `$5 = alloc::rc::Rc<&str, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::rc::RcInner<&str>> {pointer: 0x6a8fd0}, phantom: core::marker::PhantomData<alloc::rc::RcInner<&str>>, alloc: alloc::alloc::Global}`
    (strings-and-strs.rs:27) `$6 = alloc::boxed::Box<str, alloc::alloc::Global> [87, 111, 114, 108, 100]`
status: exit code: 0
command: PATH="D:\a\rust\rust\build\x86_64-pc-windows-gnu\stage2\lib\rustlib\x86_64-pc-windows-gnu\lib;D:\a\rust\rust\build\x86_64-pc-windows-gnu\bootstrap-tools\x86_64-pc-windows-gnu\release\deps;D:\a\rust\rust\ninja;D:\a\rust\rust\mingw64\bin;C:\msys64\usr\bin;D:\a\rust\rust\sccache;C:\Program Files\MongoDB\Server\7.0\bin;C:\vcpkg;C:\tools\zstd;C:\hostedtoolcache\windows\stack\3.9.3\x64;C:\cabal\bin;C:\ghcup\bin;C:\mingw64\bin;C:\Program Files\dotnet;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\R\R-4.6.0\bin\x64;C:\SeleniumWebDrivers\GeckoDriver;C:\SeleniumWebDrivers\EdgeDriver;C:\SeleniumWebDrivers\ChromeDriver;C:\Program Files (x86)\sbt\bin;C:\Program Files (x86)\GitHub CLI;C:\Program Files\Git\bin;C:\Program Files (x86)\pipx_bin;C:\npm\prefix;C:\hostedtoolcache\windows\go\1.24.13\x64\bin;C:\hostedtoolcache\windows\Python\3.12.10\x64\Scripts;C:\hostedtoolcache\windows\Python\3.12.10\x64;C:\hostedtoolcache\windows\Ruby\3.3.11\x64\bin;C:\Program Files\OpenSSL\bin;C:\tools\kotlinc\bin;C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\17.0.19-10\x64\bin;C:\Program Files\ImageMagick-7.1.2-Q16-HDRI;C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin;C:\ProgramData\kind;C:\ProgramData\Chocolatey\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\PowerShell\7;C:\Program Files\Microsoft\Web Platform Installer;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\dotnet;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files (x86)\WiX Toolset v3.14\bin;C:\Program Files\Microsoft SQL Server\130\DTS\Binn;C:\Program Files\Microsoft SQL Server\140\DTS\Binn;C:\Program Files\Microsoft SQL Server\150\DTS\Binn;C:\Program Files\Microsoft SQL Server\160\DTS\Binn;C:\Program Files\Microsoft SQL Server\170\DTS\Binn;C:\ProgramData\chocolatey\lib\pulumi\tools\Pulumi\bin;C:\Program Files\CMake\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.9.15\bin;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\nodejs;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\GitHub CLI;C:\tools\php;C:\Program Files (x86)\sbt\bin;C:\Program Files\Amazon\AWSCLIV2;C:\Program Files\Amazon\SessionManagerPlugin\bin;C:\Program Files\Amazon\AWSSAMCLI\bin;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\mongosh;C:\Program Files\LLVM\bin;C:\Program Files (x86)\LLVM\bin;C:\Users\runneradmin\.dotnet\tools;C:\Users\runneradmin\.cargo\bin;C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps" "D:\\a\\rust\\rust\\mingw64\\bin\\gdb" "-quiet" "-batch" "-nx" "-command=D:\\a\\rust\\rust\\build\\x86_64-pc-windows-gnu\\test\\debuginfo\\strings-and-strs.gdb\\strings-and-strs.debugger.script"
--- stdout -------------------------------
GNU gdb (GDB) 14.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Breakpoint 1 at 0x140001f67: file tests\debuginfo/strings-and-strs.rs, line 70.

Breakpoint 1, strings_and_strs::main () at tests\debuginfo/strings-and-strs.rs:70
70     zzz(); // #break
$1 = alloc::string::String {vec: alloc::vec::Vec<u8, alloc::alloc::Global> {buf: alloc::raw_vec::RawVec<u8, alloc::alloc::Global> {inner: alloc::raw_vec::RawVecInner<alloc::alloc::Global> {ptr: core::ptr::unique::Unique<u8> {pointer: core::ptr::non_null::NonNull<u8> {pointer: 0x6a5df0}, _marker: core::marker::PhantomData<u8>}, cap: core::num::niche_types::UsizeNoHighBit (5), alloc: alloc::alloc::Global}, _marker: core::marker::PhantomData<u8>}, len: 5}}
$2 = "Hello"
$3 = strings_and_strs::Foo {inner: "Hello"}
$4 = ("Hello", "World")
$5 = alloc::rc::Rc<&str, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::rc::RcInner<&str>> {pointer: 0x6a8fd0}, phantom: core::marker::PhantomData<alloc::rc::RcInner<&str>>, alloc: alloc::alloc::Global}
$6 = alloc::boxed::Box<str, alloc::alloc::Global> [87, 111, 114, 108, 100]
$7 = alloc::rc::Rc<str, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::rc::RcInner<str>> {pointer: *const alloc::rc::RcInner<str> [alloc::rc::RcInner<str> {strong: core::cell::Cell<usize> {value: core::cell::UnsafeCell<usize> {value: 1}}, weak: core::cell::Cell<usize> {value: core::cell::UnsafeCell<usize> {value: 1}}, value: 0x6a48f0}, alloc::rc::RcInner<str> {strong: core::cell::Cell<usize> {value: core::cell::UnsafeCell<usize> {value: 13451671976132374359}}, weak: core::cell::Cell<usize> {value: core::cell::UnsafeCell<usize> {value: 12370169555311111083}}, value: 0x6a4900}, alloc::rc::RcInner<str> {strong: core::cell::Cell<usize> {value: core::cell::UnsafeCell<usize> {value: 12370169555311111083}}, weak: core::cell::Cell<usize> {value: core::cell::UnsafeCell<usize> {value: 18369900232523579118}}, value: 0x6a4910}, alloc::rc::RcInner<str> {strong: core::cell::Cell<usize> {value: core::cell::UnsafeCell<usize> {value: 0}}, weak: core::cell::Cell<usize> {value: core::cell::UnsafeCell<usize> {value: 0}}, value: 0x6a4920}, alloc::rc::RcInner<str> {strong: core::cell::Cell<usize> {value: core::cell::UnsafeCell<usize> {value: 18369900232523579118}}, weak: core::cell::Cell<usize> {value: core::cell::UnsafeCell<usize> {value: 266956156054182}}, value: 0x6a4930}]}, phantom: core::marker::PhantomData<alloc::rc::RcInner<str>>, alloc: alloc::alloc::Global}
A debugging session is active.

 Inferior 1 [process 7404] will be killed.

Quit anyway? (y or n) [answered Y; input not from terminal]
------------------------------------------
stderr: none

---- [debuginfo-gdb] tests\debuginfo\strings-and-strs.rs stdout end ----

---

Some tests failed in compiletest suite=debuginfo mode=debuginfo host=x86_64-pc-windows-gnu target=x86_64-pc-windows-gnu
Bootstrap failed while executing `test --stage 2 --skip=compiler --skip=src`
Build completed unsuccessfully in 1:52:07
make: *** [Makefile:126: ci-mingw-x] Error 1
  local time: Sat May 16 12:30:20 CUT 2026
  network time: Sat, 16 May 2026 12:30:21 GMT
##[error]Process completed with exit code 2.
##[group]Run echo "disk usage:"
echo "disk usage:"

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 16, 2026

💔 Test for 2468142 failed: CI. Failed job:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants